home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 43
/
Amiga Format CD43 (1999)(Future Publishing)(GB)(Track 1 of 2)[!][issue 1999-09].iso
/
-serious-
/
programming
/
c
/
memlib
/
developer
/
source
/
mwstrdup.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-06-14
|
1KB
|
30 lines
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* |_o_o|\\ Copyright (c) 1994 Doug Walker *
* |. o.| || All Rights Reserved *
* | . | || Written by Doug Walker *
* | o | || 4701 Oak Park Road *
* | . |// Raleigh, NC 27612 *
* ====== *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "mempriv.h"
#include <string.h>
char *MWStrDup(const char *str, char *file, long line)
{
char *mem;
if(str == NULL)
{
MWPrintf("%sMemWatch ERROR: strdup(NULL) called from file \"%s\" line %d\n", MW_NEWLINE,
file, line);
return NULL;
}
// Pass file and line along so any future memory error messages show the
// line of the strdup() call and not this one.
mem = MWAllocMem(strlen(str)+1, 0, MWI_MALLOC, file, line);
if(mem) strcpy(mem, str);
return mem;
}